// pages/index_sixitem_Experience/index_sixitem_Experience.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    part: false,
    all: false,
    experience_review_src: [
      "../../static/images/index/star.jpg",
      "../../static/images/index/star.jpg",
      "../../static/images/index/star.jpg",
      "../../static/images/index/star.jpg",
      "../../static/images/index/star.jpg"
    ],
    article_review_src: [
      "../../static/images/index/star.jpg",
      "../../static/images/index/star.jpg",
      "../../static/images/index/star.jpg",
      "../../static/images/index/star.jpg",
      "../../static/images/index/star.jpg"
    ],
    repair: "提高个人修养所做的努力。",
    qi: "今日为提高个人修养所做的努力。",
    build: "今日为提高个人修养所做的努力。",
    back: "今日为提高个人修养所做的努力。",
    sense: "今日为提高个人修养所做的努力。"
  },
  // 提交心得
  ReviewChange(index) {
    let list = this.data.experience_review_src;
    if (index == 0) {
      for (let i = 0; i < 5; i++) {
        list[i] = "../../static/images/index/star_select.jpg";
      }
    } else if (index == 1) {
      for (let i = 0; i < 5; i++) {
        if (index - 1 >= i) {
          list[i] = "../../static/images/index/star.jpg";
        } else {
          list[i] = "../../static/images/index/star_select.jpg";
        }
      }

    } else if (index == 2) {
      for (let i = 0; i < 5; i++) {
        if (index - 1 >= i) {
          list[i] = "../../static/images/index/star.jpg";
        } else {
          list[i] = "../../static/images/index/star_select.jpg";
        }
      }
    } else if (index == 3) {
      for (let i = 0; i < 5; i++) {
        if (index - 1 >= i) {
          list[i] = "../../static/images/index/star.jpg";
        } else {
          list[i] = "../../static/images/index/star_select.jpg";
        }
      }
    } else if (index == 4) {
      for (let i = 0; i < 5; i++) {
        if (index - 1 >= i) {
          list[i] = "../../static/images/index/star.jpg";
        } else {
          list[i] = "../../static/images/index/star_select.jpg";
        }
      }
    }

    this.setData({
      experience_review_src: list
    })
  },
  // 阅读文章
  ArticleChange(index) {
    let list = this.data.article_review_src;
    if (index == 0) {
      for (let i = 0; i < 5; i++) {
        list[i] = "../../static/images/index/star_select.jpg";
      }
    } else if (index == 1) {
      for (let i = 0; i < 5; i++) {
        if (index - 1 >= i) {
          list[i] = "../../static/images/index/star.jpg";
        } else {
          list[i] = "../../static/images/index/star_select.jpg";
        }
      }

    } else if (index == 2) {
      for (let i = 0; i < 5; i++) {
        if (index - 1 >= i) {
          list[i] = "../../static/images/index/star.jpg";
        } else {
          list[i] = "../../static/images/index/star_select.jpg";
        }
      }
    } else if (index == 3) {
      for (let i = 0; i < 5; i++) {
        if (index - 1 >= i) {
          list[i] = "../../static/images/index/star.jpg";
        } else {
          list[i] = "../../static/images/index/star_select.jpg";
        }
      }
    } else if (index == 4) {
      for (let i = 0; i < 5; i++) {
        if (index - 1 >= i) {
          list[i] = "../../static/images/index/star.jpg";
        } else {
          list[i] = "../../static/images/index/star_select.jpg";
        }
      }
    }

    this.setData({
      article_review_src: list
    })
  },
  // 提交心得items
  onReviewSrcChange1() {
    this.ReviewChange(0)
  },
  onReviewSrcChange2() {
    this.ReviewChange(1)
  },
  onReviewSrcChange3() {
    this.ReviewChange(2)
  },
  onReviewSrcChange4() {
    this.ReviewChange(3)
  },
  onReviewSrcChange5() {
    this.ReviewChange(4)
  },

  //  阅读文章items
  onArticleSrcChange1() {
    this.ArticleChange(0)
  },
  onArticleSrcChange2() {
    this.ArticleChange(1)
  },
  onArticleSrcChange3() {
    this.ArticleChange(2)
  },
  onArticleSrcChange4() {
    this.ArticleChange(3)
  },
  onArticleSrcChange5() {
    this.ArticleChange(4)
  },
  // 小组可看
  onChangePart(event) {
    const detail = event.detail;
    this.setData({
      'part': detail.value
    })
  },

  // 全部可看
  onChangeAll(event) {
    const detail = event.detail;
    this.setData({
      'all': detail.value
    })
  },
  // 复制
  copy(e) {
    wx.setClipboardData({
      data: e.currentTarget.dataset.text,
      success: function (res) {
        wx.getClipboardData({
          success: function (res) {
            wx.showToast({
              title: '复制成功'
            })
          }
        })
      }
    })
  },

  // 复制文本（修身）
  copyTextRepair: function (e) {
    this.copy(e);
  },
  // 复制文本（齐家）
  copyTextQi: function (e) {
    this.copy(e);
  },
  // 复制文本（建工）
  copyTextBuild: function (e) {
    this.copy(e);
  },
  // 复制文本（反省）
  copyTextBack: function (e) {
    this.copy(e);
  },
  // 复制文本（感谢）
  copyTextSense: function (e) {
    this.copy(e);
  },

  // 获取文本框值（修身）
  onRepairChange(e) {
    this.setData({
      repair: e.detail.value
    })
  },
  // 获取文本框值（齐家）
  onQiChange(e) {
    this.setData({
      qi: e.detail.value
    })
  },
  // 获取文本框值（建工）
  onBuildChange(e) {
    this.setData({
      build: e.detail.value
    })
  },
  // 获取文本框值（反省）
  onBackChange(e) {
    this.setData({
      back: e.detail.value
    })
  },
  // 获取文本框值（感谢）
  onSenseChange(e) {
    this.setData({
      sense: e.detail.value
    })
  },
  // 暂存
  onStorage() {
    console.log("暂存")
  },
  // 提交
  onSend() {
    console.log("提交")
  }

})